/**
业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            businessCenterInfo: {
                searchValue: '',
                shopVipUserDtos: [],
                productDtos: [],
                storeOrderCartDtos: [],
                storeOrderCartReturnDtos: [],
                productGroupDtos: [],
                productGroupOrderDtos: [],
                productSeckillDtos: [],
                productSeckillOrderDtos: [],
                housekeepingServDtos: [],
                housekeepingResourceDtos: [],
                _currentTab: 'businessDetailUser',
            }
        },
        _initMethod: function () {

        },
        _initEvent: function () {
            vc.on('businessCenter', 'listCarData', function (_info) {
                //$that._loadFeeDetailInfo();
                $that.changeTab($that.businessCenterInfo._currentTab);
            });
        },
        methods: {
            _doSearch: function (_page, _rows) {
                let param = {
                    params: {
                        searchValue: $that.businessCenterInfo.searchValue,
                        shopId: vc.getCurrentCommunity().shopId,
                    }
                };

                //发送get请求
                vc.http.apiGet('/business.businessQuery',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data, $that.businessCenterInfo);
                        $that.selectHasDataTab();
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            selectHasDataTab(){
                let _that = $that.businessCenterInfo;
               
                if(_that.shopVipUserDtos.length>0){
                    $that.changeTab('businessDetailUser');
                    return;
                }
                if(_that.productDtos.length>0){
                    $that.changeTab('businessDetailGoods');
                    return;
                }
                if(_that.storeOrderCartDtos.length>0){
                    $that.changeTab('businessDetailOrder');
                    return;
                }
                if(_that.storeOrderCartReturnDtos.length>0){
                    $that.changeTab('businessDetailRefund');
                    return;
                }
                if(_that.productGroupDtos.length>0){
                    $that.changeTab('businessDetailGroup');
                    return;
                }
                if(_that.productGroupOrderDtos.length>0){
                    $that.changeTab('businessDetailGroupOrder');
                    return;
                }
                if(_that.productSeckillDtos.length>0){
                    $that.changeTab('businessDetailSeckill');
                    return;
                }
                if(_that.productSeckillOrderDtos.length>0){
                    $that.changeTab('businessDetailSeckillOrder');
                    return;
                }
                if(_that.housekeepingServDtos.length>0){
                    $that.changeTab('businessDetailService');
                    return;
                }
                if(_that.housekeepingResourceDtos.length>0){
                    $that.changeTab('businessDetailResource');
                    return;
                }
            },
            changeTab: function (_tab) {
                $that.businessCenterInfo._currentTab = _tab;

                vc.emit(_tab, 'switch', $that.businessCenterInfo);
            },

        }
    });
})(window.vc);